//统一管理api接口
import mockAjax from "./mockInit"
import axios from "./axiosinit"
import { nanoid } from "nanoid"


export const BkTenYearOfGet = ()=>{
    //返回的是promise对象
    return mockAjax({
        url:'/BkTenYearOf',
        method:'GET'
    })
}

//获取图片验证码
export const getCaptcha = ()=>{
    return axios({
        url:'/regAndLog/captcha',
        method:'GET',
    })
}


//注册
export const postRegister = (obj)=>{
    return axios({
        url:'/regAndLog/postRegister',
        method:'POST',
        headers:{
            'Content-Type': 'application/json'
        },
        data:obj
    })
}

//登录
export const postLogin = (obj)=>{
    return axios({
        url:'/regAndLog/postLogin',
        method:'POST',
        headers:{
            'Content-Type': 'application/json'
        },
        data:obj
    })
}

//登录用户判断
export const getLoginJudge = ()=>{
    return axios({
        url:'/regAndLog/getLoginJudge',
        method:'GET',
    })
}

//退出登录

export const getExitLogin = ()=>{
    return axios({
        url:'/regAndLog/getExitLogin',
        method:'GET',
    })
}

//发送背景图片 

export const postbkImage = (formDate)=>{
    return axios({
        url:'/personalCenter/userBackgroundimage',
        method:'POST',
        data:formDate
    })
}

//直接修改签名
export const postChangeSignature = (value)=>{
    return axios({
        url:'/personalCenter/ChangeSignature',
        method:'POST',
        data:{signature:value}
    })
}

//修改个人中心信息

export const postChangePersonalMessage = (obj)=>{
    return axios({
        url:'/personalCenter/ChangePersonalMessage',
        method:'POST',
        data:obj
    })
}

//上传头像
export const postSendHeaderImage = (formDate)=>{
    return axios({
        url:'/personalCenter/SendHeaderImage',
        method:'POST',
        data:formDate
    })
}

//密码校验

export const postSendPassword = (password)=>{
    return axios({
        url:'/personalCenter/SendPassword',
        method:'POST',
        data:{password}
    })
}

//修改密码
export const postChangePassword = (password)=>{
    return axios({
        url:'/personalCenter/ChangePassword',
        method:'POST',
        data:{password}
    })
}

//YI
export const postYI = (str)=>{
    return axios({
        url:'/personalCenter/YI',
        method:'POST',
        data:{str}
    })
}


//富文本图片插入
export const postInsertPic = (formDate)=>{
    return axios({
        url:'/personalCenter/InsertPic',
        method:'POST',
        headers:{
            'message':nanoid(10)
        },
        data:formDate
    })
}

//其他资源发送
export const postOtherSource = (obj)=>{
    return axios({
        url:'/personalCenter/postOtherSource',
        method:'POST',
        data:obj
    })
}

//图片发送
export const postImageSource = (formData,article_id)=>{
    return axios({
        url:'/personalCenter/postImageSource',
        method:'POST',
        headers:{
            article_id
        },
        data:formData
    })
}
//默认发送
export const postUseDefaultImg = (article_id)=>{
    return axios({
        url:'/personalCenter/postUseDefaultImg',
        method:'POST',
        data:{article_id}
    })
}

//two_source 发送
export const postTwoSource = (str)=>{
    return axios({
        url:'/personalCenter/postTwoSource',
        method:'POST',
        data:{str}
    })
}

//two_source 获取
export const getTwoSource = ()=>{
    return axios({
        url:'/personalCenter/getTwoSource',
        method:'GET',
    })
}

//获取yi
export const getYi = ()=>{
    return axios({
        url:'/base/getYi',
        method:'GET',
    })
}

//获取文章列表
export const postArticleList = (one_source,page,sort)=>{
    return axios({
        url:'/base/postArticleList',
        method:'POST',
        data:{one_source,page,sort}
    })
}

//总查询
export const postArticleListMain = (time,page,tags,sort,way,title)=>{
    return axios({
        url:'/base/postArticleListMain',
        method:'POST',
        data:{time,page,tags:tags.toString(),sort,way,title}
    })
}

//搜索查询
export const postSearch = (queryString)=>{
    return axios({
        url:'/base/postSearch',
        method:'POST',
        data:{queryString}
    })
}

//真搜索查询
export const postSearchTrue = (item)=>{
    return axios({
        url:'/base/postSearchTrue',
        method:'POST',
        data:{item}
    })
}

//单独查询
export const postDetail = (article_id)=>{
    return axios({
        url:'/base/postDetail',
        method:'POST',
        data:{article_id}
    })
}

//点击量增加
export const postClickAdd = (article_id)=>{
    return axios({
        url:'/base/postClickAdd',
        method:'POST',
        data:{article_id}
    })
}

//点赞文章
export const postZan = (item,article_id)=>{
    return axios({
        url:'/detail/postZan',
        method:'POST',
        data:{item,article_id}
    })
}

//收藏文章
export const postStart = (item,article_id)=>{
    return axios({
        url:'/detail/postStart',
        method:'POST',
        data:{item,article_id}
    })
}

//当前用户是否已点赞和已收藏
export const postIfLikeAndStart = (article_id)=>{
    return axios({
        url:'/detail/postIfLikeAndStart',
        method:'POST',
        data:{article_id}
    })
}

//直接评论
export const postCommentDirect = (article_id,content)=>{
    return axios({
        url:'/detail/postCommentDirect',
        method:'POST',
        data:{article_id,content}
    })
}

//评论列表
export const postComment = (article_id)=>{
    return axios({
        url:'/base/postComment',
        method:'POST',
        data:{article_id}
    })
}
//回复评论
export const postCommentReply = (article_id,father_id,reply_id,root_id,content)=>{
    return axios({
        url:'/detail/postCommentReply',
        method:'POST',
        data:{article_id,father_id,reply_id,root_id,content}
    })
}

//点赞评论
export const postDianZan = (num,comment_id)=>{
    return axios({
        url:'/detail/postDianZan',
        method:'POST',
        data:{num,comment_id}
    })
}

//最新评论
export const getNewComments = ()=>{
    return axios({
        url:'/base/getNewComments',
        method:'GET',
    })
}

//用户收藏
export const getStart = (page)=>{
    return axios({
        url:'/personalCenter/getStart',
        method:'GET',
        params:{page}
    })
}
//取消收藏
export const deleteStart = (article_id)=>{
    return axios({
        url:'/personalCenter/deleteStart',
        method:'DELETE',
        data:{article_id}
    })
}
//获取文章列表
export const getDetailWrite = (page)=>{
    return axios({
        url:'/personalCenter/getDetail',
        method:'GET',
        params:{page}
    })
}

//删除文章
export const deleteDetailWrite = (article_id)=>{
    return axios({
        url:'/personalCenter/deleteDetail',
        method:'DELETE',
        data:{article_id}
    })
}
//获取要修改的文章信息
export const getDetailEdit = (article_id)=>{
    return axios({
        url:'/personalCenter/getDetailEdit',
        method:'GET',
        params:{article_id}
    })
}

//编辑文章保存资源
export const postSaveOtherSource = (obj)=>{
    return axios({
        url:'/personalCenter/postSaveOtherSource',
        method:'POST',
        data:obj
    })
}

export const postSaveImageSource = (formData,article_id)=>{
    return axios({
        url:'/personalCenter/postSaveImageSource',
        method:'POST',
        headers:{
            article_id
        },
        data:formData
    })
}


